package com.lmy.springCloud.service;

import com.lmy.springCloud.entity.Member;
import com.lmy.springCloud.utils.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Component
@FeignClient(value = "MEMBER-SERVICE-PROVIDER")
public interface MemberFeignService {

    /*
        定义方法-就是远程调用的接口
        1.远程调用的方式是get
        2.远程调用的url http://MEMBER-SERVICE-PROVIDER/getMemberById/{id}
        3.@RequestMapping(value = "/getMemberById/{id}", method = RequestMethod.GET)
          应该和远程调用方的uri和请求方式保持一致，这样openFeign才能进行url拼接
        4.@FeignClient(value = "MEMBER-SERVICE-PROVIDER")
          MEMBER-SERVICE-PROVIDER就是服务提供方在EurekaService注册的服务
        5.openFeign会根据负载均衡来决定调用9090/9091，默认是轮询算法
        6.使用openFeign的好处：支持Springmvc注解 + 接口解耦
        7.openFeign默认超时时间1s，即等待返回结果1s
     */
    @RequestMapping(value = "/getMemberById/{id}", method = RequestMethod.GET)
    public Result<Member> getMemberById(@PathVariable(value = "id") Long id);

}
